package switchviz.gui.component;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;

import switchviz.core.ResourceManager;

public class SlidePanel extends JPanel
{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6520431437975461291L;
	private JSlider _slrenderrate = null;
	private JLabel _lbltext = null;
	
	public void setText(String text)
	{
		_lbltext.setText(text);
	}
	
	public JSlider getSlider()
	{
		return _slrenderrate;
	}
	
	public int getValue()
	{
		return _slrenderrate.getValue();
	}
	
	public SlidePanel(String text, int min, int max, int val, Dimension labelwidth)
	{
		_slrenderrate = new JSlider(min, max, val);
		_slrenderrate.setMajorTickSpacing(5);
		_slrenderrate.setMinorTickSpacing(1);
		_slrenderrate.setPaintTicks(true);
		_slrenderrate.setPaintLabels(true);
		_slrenderrate.setSnapToTicks(true);

		this.setLayout(ResourceManager.getInstance().getBorderLayout());
		_lbltext = new JLabel(text, JLabel.TRAILING);
		_lbltext.setPreferredSize(labelwidth);
		this.add(_lbltext, BorderLayout.WEST);
		this.add(_slrenderrate, BorderLayout.CENTER);
		this.setMaximumSize(new Dimension(800, 80));
	}
	
	public SlidePanel(String text, int min, int max, int val)
	{
		this(text, min, max, val, ResourceManager.getInstance().getConfigurationLabelDimension());
	}
}
